﻿@namespace ThingsGateway.Debug
@using Microsoft.AspNetCore.Components.Routing
@using System.Reflection


<Router AppAssembly="@typeof(BlazorApp).Assembly" AdditionalAssemblies="_assemblyList">
    <Found Context="routeData">
        <RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
    </Found>
    <NotFound>
        <LayoutView Layout="@typeof(MainLayout)">
            <p role="alert">Sorry, there's nothing at this address.</p>
        </LayoutView>
    </NotFound>
</Router>


@code {
    private List<Assembly> _assemblyList = new();
    protected override void OnInitialized()
    {
        _assemblyList = AppDomain.CurrentDomain.GetAssemblies().SelectMany(a =>
        a.GetTypes()).Where(u => !u.IsInterface && !u.IsAbstract && u.IsClass
    && u.IsDefined(typeof(Microsoft.AspNetCore.Components.RouteAttribute), true)).Select(a => a.Assembly)
    .Where(a => a != typeof(BlazorApp).Assembly)
    .Distinct().ToList();
        base.OnInitialized();
    }
}
